﻿using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using PublicCommon;
using T_Material.Domain;
using T_Material.Read.API.Application.Commands.PurchaseCommand;

namespace T_Material.Read.API.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class PurchaseRApiController : ControllerBase
    {
        private readonly IMediator mediator;

        public PurchaseRApiController(IMediator mediator)
        {
            this.mediator = mediator;
        }

        /// <summary>
        /// 物资采购列表
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<PageResult<Purchase>> GetPurchaseList([FromQuery] PurchaseListCommand command)
        {
            return await mediator.Send(command);
        }
        /// <summary>
        /// 物资采购列表没有提交
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<PageResult<Purchase>> GetPurchaseListState([FromQuery] PurchaseListStateCommand command)
        {
            return await mediator.Send(command);
        }

        /// <summary>
        /// 根据物资采购Id找到物资实体
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<Purchase> GetPurchaseInfo([FromQuery] PurchaseInfoCommand command)
        {
            return await mediator.Send(command);
        }
    }
}
